package com.zbcz.erp.activity

import android.os.Bundle
import androidx.core.widget.addTextChangedListener
import com.zbcz.erp.adapter.BusinessListAdapter
import com.zbcz.erp.bean.BusinessListBean
import com.zbcz.erp.databinding.ActivityChooseBusinessTripBinding
import com.zbcz.erp.util.DensityUtils
import com.zbcz.erp.util.onSingleClick

/**
 * 选择出差申请表
 */
class ChooseBusinessTripActivity : BaseActivity() {

    companion object {
        val testList = listOf(BusinessListBean("1"), BusinessListBean("2"))
    }


    private lateinit var mBinding: ActivityChooseBusinessTripBinding


    override fun onCreate(savedInstanceState: Bundle?) {
        mBinding = ActivityChooseBusinessTripBinding.inflate(layoutInflater)
        setContentView(mBinding.root)
        init()
        super.onCreate(savedInstanceState)
    }

    private var mAdapter: BusinessListAdapter? = null

    fun init() {
        mBinding.clParent.setPadding(
            0,
            DensityUtils.dp2px(this, 48f),
            0,
            0
        )
        mBinding.clTitle.ivCommonBack.onSingleClick {
            finish()
        }
        mBinding.clTitle.tvTitle.text = "选择出差申请表"
        mBinding.rcList.adapter
        mAdapter = BusinessListAdapter()
        mBinding.rcList.adapter = mAdapter
        mAdapter?.submitList(testList)
        mBinding.editText.addTextChangedListener {
            val queryText = it.toString()
            mAdapter?.filterByTitle(queryText)
        }
    }
}